export * from './useThrottle';
import { useThrottle, useThrottleFn } from './useThrottle';
export * from './useDebounce';
import { useDebounce, useDebounceFn } from './useDebounce';

/**
 * 组合防抖和节流 Hook
 * 可以根据需要选择使用防抖或节流
 */
export function useDebounceThrottle() {
  /**
   * 防抖 Ref
   */
  const useDebounceRef = <T>(value: T, delay: number) => {
    return useDebounce(value, delay);
  };

  /**
   * 节流 Ref
   */
  const useThrottleRef = <T>(value: T, delay: number) => {
    return useThrottle(value, delay);
  };

  /**
   * 防抖函数
   */
  const useDebounceFunction = <T extends (..._args: any[]) => any>(
    fn: T,
    delay: number
  ) => {
    return useDebounceFn(fn, delay);
  };

  /**
   * 节流函数
   */
  const useThrottleFunction = <T extends (..._args: any[]) => any>(
    fn: T,
    delay: number,
    options?: { leading?: boolean; trailing?: boolean }
  ) => {
    return useThrottleFn(fn, delay, options);
  };

  return {
    useDebounceRef,
    useThrottleRef,
    useDebounceFunction,
    useThrottleFunction
  };
}